#!/bin/bash

##################################################
#
#  @desc: 设备ID绑定SPARK计算任务
#  @auth: HUNTER.DUAN
#  @date: 2020-08-11
#  @param_1: 可传指定计算日期
#  @param_2: 可传指定绑定参照日   
#   
##################################################

export SPARK_HOME=/opt/apps/spark-2.4.0


pre_day=`date -d'-2 day' +%Y-%m-%d`
cur_day=`date -d'-1 day' +%Y-%m-%d`

if [[ $1 && $2 ]]
then
cur_day=$1
pre_day=$2
fi

${SPARK_HOME}/bin/spark-submit  --master yarn \
--deploy-mode client \
--num-executors 3 \
--executor-memory 3g \
--executor-cores 1 \
--class cn.doitedu.dwetl.idmp.AppIdBInd /opt/job_scripts/etl.jar ${cur_day} ${pre_day} yarn


if [ $? -eq 0 ]
then 
echo "execution succeed ,a mail has been sent ........."
else
echo "execution failed ,a mail has been sent ........."
fi
